package com.zhangx.datastructure.stacklist;

/**
 * 菲波那切数列
 */
public class FibonacciSeq {

    /**
     * 最简单的方式
     */
    public void simple(){
        int a[] = new int[40];
        a[0] = 0;
        a[1] = 1;
        for (int i = 2; i < a.length; i++) {
            a[i] = a[i-1] + a[i-2];
            System.out.println("----"+i+"----");
            System.out.println(a[i]);
        }
    }

    public int fbi(int n){
        if (n==1){
            return 1;
        }
        if (n==0){
            return 0;
        }
        return fbi(n-1)+fbi(n-2);
    }

    public static void main(String[] args) {
        FibonacciSeq fibonacciSeq = new FibonacciSeq();
        fibonacciSeq.simple();

        System.out.println(fibonacciSeq.fbi(39));

    }
}
